const Service = require('egg').Service;

class VersionService extends Service {
    findVersions(condition) {
        return this.ctx.model.Version.find(condition).sort('-createDate').lean();
    }

    updateVersion(id, data) {
        return this.ctx.model.Version.findOneAndUpdate({ _id: id }, { ...data }, { new: true }).lean();
    }

    removeVersionStatus(siteId) {
        return this.ctx.model.Version.updateMany({ status: 1, siteId }, { status: 0 }).lean();
    }
}

module.exports = VersionService;
